package com.fengxing.ams.web.action;

import java.util.Random;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fengxing.ams.pub.manager.intf.IConfigManager;
import com.fengxing.ams.web.action.view.ResponseVO;
import com.fengxing.ams.web.common.IContextManager;
import com.fengxing.ams.web.facade.intf.INotifyFacade;
import com.fengxing.ams.web.facade.intf.IOrderFacade;
import com.fengxing.ams.web.facade.intf.IStudentFacade;
import com.fengxing.ams.web.facade.intf.ISysManagerFacade;
import com.fengxing.ams.web.facade.intf.IUserFacade;
import com.fengxing.ams.web.facade.mouble.company.CompanyVO;
import com.fengxing.ams.web.facade.mouble.user.UserVO;

@Controller
@RequestMapping("company")
@Transactional
public class CompanyAction {
	
	private Log logger = LogFactory.getLog(CompanyAction.class);
	
	@Autowired
	private IUserFacade userFacade;
	@Autowired
	private INotifyFacade notifyFacade;
	@Autowired
	private IContextManager contextManager;
	@Autowired
	private IConfigManager configManager;
	@Autowired
	private ISysManagerFacade sysManagerFacade;
	@Autowired
	private IOrderFacade orderFacade;
	@Autowired
	private IStudentFacade studentFacade;
	
	private static final Random r = new Random();
	
	@RequestMapping(value = "/queryByStudentId.do", method = RequestMethod.POST)
	public @ResponseBody ResponseVO studentProfile() {
		//先检查context中是否有user
		ResponseVO vo = new ResponseVO();
		UserVO loginedUser = this.contextManager.getUserVO();

		//使用email，到学生表中查询信息
		CompanyVO company = this.studentFacade.queryCompanyByStudentId(loginedUser.getEmail());
		
		vo.setData(company);
		vo.setMessage("请求成功！");
		return vo;
	}
	
}
